package com.punch.order.controller;


import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.query.order.SettlementQueryInfo;
import com.punch.common.vo.course.MaterialSettlementVO;
import com.punch.common.vo.order.ClassSettlementPageVO;
import com.punch.common.vo.order.SettlementPageVO;
import com.punch.order.service.CourseSettlementService;
import com.punch.order.service.MaterialSettlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(hidden = true)
public class SettlementController {

    @Resource
    private MaterialSettlementService materialSettlementService;

    @Resource
    private CourseSettlementService courseSettlementService;

    /**
     * 课程结算列表
     *
     * @param settlementQueryInfo 结算订单查询信息
     * @return SettlementPageVO
     */
    @GetMapping(value = "/order/course/settlements", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "课程结算列表", notes = "课程结算列表", produces = "application/json")
    public Result<PageInfo<SettlementPageVO>> listCourseSettlement(@ModelAttribute SettlementQueryInfo settlementQueryInfo) {
        return Result.succeed(courseSettlementService.listCourseSettlement(settlementQueryInfo));
    }

    /**
     * 课程结算班级列表
     *
     * @param settlementQueryInfo 结算id
     * @return ClassSettlementPageVO
     */
    @GetMapping(value = "/order/course/settlement/class", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "课程结算班级列表", notes = "课程结算班级列表", produces = "application/json")
    public Result<PageInfo<ClassSettlementPageVO>> listCourseClassSettlement(@ModelAttribute SettlementQueryInfo settlementQueryInfo) {
        return Result.succeed(courseSettlementService.listCourseClassSettlement(settlementQueryInfo));
    }


    /**
     * 课程结算修改状态
     *
     * @param settlementId 结算id
     * @return settlementId
     */
    @PutMapping(value = "/order/course/settlement/{settlementId}/{settlementStatus}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "课程结算修改状态", notes = "课程结算修改状态", produces = "application/json")
    public Result<Long> updateCourseSettlementStatus(@PathVariable Long settlementId, @PathVariable Integer settlementStatus) {
        return Result.succeed(courseSettlementService.updateCourseSettlementStatus(settlementId, settlementStatus));
    }

    /**
     * 教具结算列表
     *
     * @param settlementQueryInfo 结算订单查询信息
     * @return SettlementPageVO
     */
    @GetMapping(value = "/order/material/settlements", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "教具结算列表", notes = "教具结算列表", produces = "application/json")
    public Result<PageInfo<SettlementPageVO>> listMaterialSettlement(@ModelAttribute SettlementQueryInfo settlementQueryInfo) {
        return Result.succeed(materialSettlementService.listMaterialSettlement(settlementQueryInfo));
    }

    /**
     * 教具结算详情
     *
     * @param settlementId 结算id
     * @return OrderMaterialSettlementVO
     */
    @GetMapping(value = "/order/material/settlement/{settlementId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "教具结算详情", notes = "教具结算列表", produces = "application/json")
    public Result<MaterialSettlementVO> getMaterialSettlement(@PathVariable Long settlementId) {
        return Result.succeed(materialSettlementService.getMaterialSettlement(settlementId));
    }


    /**
     * 教具结算修改状态
     *
     * @param settlementId 结算id
     * @return settlementId
     */
    @PutMapping(value = "/order/material/settlement/{settlementId}/{settlementStatus}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "教具结算修改状态", notes = "教具结算修改状态", produces = "application/json")
    public Result<Long> updateMaterialSettlementStatus(@PathVariable Long settlementId, @PathVariable Integer settlementStatus) {
        return Result.succeed(materialSettlementService.updateMaterialSettlementStatus(settlementId, settlementStatus));
    }
}
